<template>
  <div class="detailed-content">
    <viHeader
      :title="title"
      :radioList="radioList"
      @enlarge="enlarge"
      @changeRadio="changeRadio"
    />
    <div class="detailed-main">
      <div class="detailed-list" v-for="item in todayList">
        <div class="tag">{{item.accountFundTypeName[0]}}</div>
        <div class="banner">
          <div class="banner-content">
            <div class="top">
              <label>{{item.deptName}}</label>
              <span v-if="item.accountType===1" class="green-1">+ {{formatNumber(item.accountAmount)}}</span>
              <span v-else class="red-1">- {{formatNumber(item.accountAmount)}}</span>
            </div>
            <div class="bottom">
              <label>{{item.accountFundTypeName}}</label>
              <span>{{item.fundAccountName}}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import viHeader from "@/components/visualization/header/index";
export default {
  name: "vi-detailed",
  components: {
    viHeader
  },
  props:{
    todayList:{
      default:()=>[]
    },
  },
  data() {
    return {
      title: {
        name: "近日明细",
        unit: "元"
      },
      radioList: {
        radio: "2",
        list: []
      }
    };
  },
  filters:{
    filaccountAmount(val){
      return (val/10000).toFixed(4)||0
    }
  },
  mounted() {},
  methods: {
    enlarge() {
      this.$emit("enlarge")
    },
    changeRadio(val) {
      console.log(val);
    },
    formatNumber(num) {
      if (!num) {
        return '0.00';
      }
      let str = String(num).split('.');
      let num1 = str[0];
      let num2 = `${str[1]}`;
      if (str[1]) {
        let data = `${str[1]}`;
        if (data.length > 2) {
          data = data.slice(0, 2);
        }
        if (data.length === 1) {
          data = `${data}0`;
        }
        num2 = `.${data}`;
        
      } else {
        num2 = '.00';
      }
      let reg = /\d{1,3}(?=(\d{3})+$)/g;
      return (num1 + '').replace(reg, '$&,') + `${num2}`;
    },
  }
};
</script>

<style scoped lang="scss">
@import "../styles/detail.scss";
</style>
